package com.ajx.blog.exception;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

@ControllerAdvice
public class ExceptionController {
     private Logger   logger  = LoggerFactory.getLogger(ExceptionController.class);
    @ExceptionHandler
    @ResponseBody
    public Map<String,Object>   returnException(Exception e){
         logger.error("方法出现异常");
        HashMap<String, Object> result = new HashMap<>();
          e.printStackTrace();
          result.put("status","error");
          result.put("msg","方法执行出现异常");
          return   result;



    }


}
